<template>
  <a-date-picker
    show-time
    format="YYYY-MM-DD"
    @change="onChange"
    @select="onSelect"
    @ok="onOk"
  />
</template>

<script setup lang="ts">
  import { ref, watch } from 'vue';

  const props = defineProps({
    value: {
      type: String,
      default: '',
    },
    placeholder: {
      type: String,
      default: '请选择',
    },
  });
  const emit = defineEmits(['update:value']);

  const nowVal = ref(props.value);
  watch(
    () => props.value,
    (newVal) => {
      nowVal.value = newVal;
    }
  );
  const onChange = () => {
    emit('update:value', nowVal.value);
    console.log(nowVal);
  };
  const onSelect = () => {
    console.log(nowVal);
  };
</script>
